<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<!--{hook admin_user_update_start.htm}-->

<div class="row">
	<div class="col-lg-8 offset-lg-2">
		<div class="btn-group m-b-1" role="group">
			<?php echo admin_tab_active($menu['pay']['tab'], 'channel');?>
		</div>
		<div class="card">
			<div class="card-block">
				<h4 class="card-title">添加通道配置</h4>
				<form action="<?php echo url("pay-hebingadd");?>" method="post" id="form">
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">通道简称：</label>
						<div class="col-sm-10">
							<input type="text" id="a_shortname" name="a_shortname" placeholder="通道取一个易懂的简称(字母表示)" class="form-control">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">通道名称：</label>
						<div class="col-sm-10">
							<input type="text" id="a_name" name="a_name" class="form-control" placeholder="通道取一个名字" >
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">支付宝APPID：</label>
						<div class="col-sm-10">
							<input type="text" id="a_api_id" name="a_api_id" class="form-control" placeholder="支付宝APPID">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">支付宝商户密匙：</label>
						<div class="col-sm-10">
							<input type="text" id="a_api_secret" name="a_api_secret" class="form-control" placeholder="支付宝商户私钥(支付宝官网下载生成在上传)">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">支付宝公匙：</label>
						<div class="col-sm-10">
							<input type="text" id="a_api_publickey" name="a_api_publickey" placeholder="支付宝公钥" class="form-control"">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">支付宝网关地址：</label>
						<div class="col-sm-10">
							<input type="text" value="https://openapi.alipay.com/gateway.do" id="a_url" name="a_url" class="form-control" placeholder="支付宝网关地址">
						</div>
					</div>
					<!--<div class="form-group row">-->
						<!--<label class="col-sm-2 form-control-label"></label>-->
						<!--<div class="col-sm-10">-->
							<!--<button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="提交中...">确认</button>-->
							<!--<a role="button" class="btn btn-secondary btn-block m-t-1" href="javascript:history.back();">返回</a>-->
						<!--</div>-->
					<!--</div>-->
				<h4 class="card-title">添加附加配置</h4>

				<!--<div class="form-group row">-->
					<!--<label class="col-sm-2 form-control-label">名称：</label>-->
					<!--<div class="col-sm-10">-->
						<!--<input type="text" id="b_name" name="b_name" class="form-control" >-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">支付宝账户：</label>
					<div class="col-sm-10">
						<input type="text" id="b_alipay_account" name="b_alipay_account" placeholder="支付宝登录账户" class="form-control"  >
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">姓名：</label>
					<div class="col-sm-10">
						<input type="text" id="b_alipay_realname" name="b_alipay_realname" class="form-control"  >
					</div>
				</div>
				<div class="form-group row">
				<label class="col-sm-2 form-control-label">所属用户：</label>
				<div class="col-sm-10">
				<select id="b_user_id" name="b_user_id" class="form-control">
				<?php foreach($users as $g){ ?>
				<option value="<?php echo $g['uid'];?>" ><?php echo $g['username'];?></option>
				<?php } ?>
				</select>
				</div>
				</div>
				<!--<div class="form-group row">-->
					<!--<label class="col-sm-2 form-control-label">所属网关：</label>-->
					<!--<div class="col-sm-10">-->
						<!--<select id="gate_id" name="gate_id" class="form-control">-->
							<!--<?php foreach($gateway as $g){ ?>-->
							<!--<option value="<?php echo $g['id'];?>"><?php echo $g['name'];?></option>-->
							<!--<?php } ?>-->
						<!--</select>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">单笔最大限额：</label>
					<div class="col-sm-10">
						<input type="text" id="b_max_limit" name="b_max_limit" placeholder="单笔最大支付金额" class="form-control"  >
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">通道最大限额：</label>
					<div class="col-sm-10">
						<input type="text" id="max_price" name="b_max_price" placeholder="通道最大收款金额" class="form-control"  >
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">地区：</label>
					<div class="col-sm-10">
						<input type="text" id="b_area" name="b_area" class="form-control"  placeholder="支付宝通道,所属地区多个逗号隔开(如:四川,重庆)"  >
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">分类：</label>
					<div class="col-sm-10">
						<select id="b_cate" name="b_cate" class="form-control selectpicker" data-live-search="true" data-style="btn-info">
							<option value="0">请选择分类</option>
							<?php foreach($cate as $c){ ?>
							<option value="<?php echo $c['id'];?>" ><?php echo $c['name'];?></option>
							<?php } ?>
						</select>
					</div>
				</div>
				<!--<div class="form-group row">-->
					<!--<label class="col-sm-2 form-control-label">HOST：</label>-->
					<!--<div class="col-sm-10">-->
						<!--<input type="text" id="b_host" name="b_host" class="form-control">-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">通道状态：</label>
					<div class="col-sm-10">
						<select id="b_is_open" name="b_is_open" class="form-control">
							<option value="1">开</option>
							<option value="0">关</option>
						</select>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2 form-control-label">安全码：</label>
					<div class="col-sm-10">
						<input type="password" id="b_passcode" name="b_passcode" class="form-control">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-2 form-control-label"></label>
					<div class="col-sm-10">
						<button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="提交中...">确认</button>
						<a role="button" class="btn btn-secondary btn-block m-t-1" href="javascript:history.back();">返回</a>
					</div>
				</div>
				</form>
			</div>
		</div>
	</div>
</div>

<!--{hook admin_user_update_end.htm}-->

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>

<link rel="stylesheet" href="view/css/bootstrap-select.css">
<script src="view/js/bootstrap-select.js"></script>
<script>
var jform = $('#form');
var jsubmit = $('#submit');
jform.on('submit', function() {
	jform.reset();
	jsubmit.button('loading');
	var postdata = jform.serialize()
	console.log(postdata);
	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			$.alert(message);
			jsubmit.text(message).delay(3000).button('reset');
            setTimeout(function () {
                window.location.href="<?php echo url('pay-channel');?>"
            },700)
		} else if(code < 0) {
			$.alert(message);
			jsubmit.button('reset');

		} else {
			alert(message);
			jform.find('[name="'+code+'"]').alert(message).focus();
			jsubmit.button('reset');
            setTimeout(function () {
                window.location.href="<?php echo url('pay-channel');?>"
            },700)
		}
	});
	return false;
});

$('#nav_pc li.user, #nav_mobile li.user').tab('show');

</script>